package com.ruibang.glass.quality.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.quality.domain.req.DefectLossReq;
import com.ruibang.glass.quality.domain.req.EveryHourDefectLossReq;
import com.ruibang.glass.quality.entity.EveryHourDefectLoss;
import com.ruibang.glass.quality.mapper.EveryHourDefectLossMapper;
import com.ruibang.glass.quality.service.EveryHourDefectLossService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 每日缺陷损失数据 服务实现类
 * </p>
 *
 * @author wujie
 * @since 2020-08-06
 */
@Service
public class EveryHourDefectLossServiceImpl extends ServiceImpl<EveryHourDefectLossMapper, EveryHourDefectLoss> implements EveryHourDefectLossService {

    @Override
    public ResultBody queryEveryHourDefectLoss(EveryHourDefectLossReq everyHourDefectLossReq) {
        final IPage<EveryHourDefectLoss> page = new Page<>(everyHourDefectLossReq.getPageNo(), everyHourDefectLossReq.getPageSize());
        return ResultBody.success(baseMapper.queryEveryHourDefectLoss(page, everyHourDefectLossReq));
    }

    @Override
    public ResultBody queryStoneLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryStoneLoss(defectLossReq));
    }

    @Override
    public ResultBody queryBubbleLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryBubbleLoss(defectLossReq));
    }

    @Override
    public ResultBody queryPlatinumLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryPlatinumLoss(defectLossReq));
    }

    @Override
    public ResultBody queryTotalLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryTotalLoss(defectLossReq));
    }

    @Override
    public void deleteHourData(DefectLossReq defectLossReq) {
        baseMapper.deleteHourData(defectLossReq);
    }

    @Override
    public List<String> getHourKey() {
        return baseMapper.getHourKey();
    }


    /**
     * @Description: 根据时间获取信息
     * @version v1.0
     * @author songJinKang
     * @date 2023-09-14 18:41
     */
    @Override
    public List<EveryHourDefectLoss> getByTime(List<String> time) {
        QueryWrapper<EveryHourDefectLoss> hlQw = new QueryWrapper<>();
        hlQw.lambda().in(EveryHourDefectLoss::getDefectTime, time);
        return this.list(hlQw);
    }
}
